home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / net / netware / nwmess.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-20  |  12.4 KB  |  384 lines

  1. {$X+,B-,V-}
  2. UNIT nwMess;
  3.  
  4. INTERFACE
  5.  
  6. Uses nwMisc;
  7.  
  8. { Function:                             Interrupt: comments:
  9.  
  10. * BroadcastToConsole                    (F215/09)
  11.   DisableStationBroadcast               (F215/02)
  12.   EnableStationBroadcast                (F215/03)
  13. * GetBroadcastMessage                   (F215/01)
  14. * GetBroadcastMode                      (DE..(..04))
  15. * SendBroadcastMessage                  (F215/00)
  16. * SendConsoleBroadcast                  (F217/D1)
  17. * SetBroadcastMode                      (DE..(..0x)), x= 0,1,2,3
  18.  
  19. NOT IMPLEMENTED:
  20.  
  21. - CheckPipeStatus                       (F215/08)  (1)
  22. - CloseMessagePipe                      (F215/07)  (1)
  23. - GetPersonalMessage                    (F215/05)  (1)
  24. - LogNetworkMessage                     (F215/0D)  (2)
  25. - OpenMessagePipe                       (F215/06)  (1)
  26. - SendPersonalMessage                   (F215/04)  (1)
  27.  
  28. Secondary Functions:
  29.  
  30. * SendMessageToUser
  31.  
  32. Notes:
  33.  (1) These calls are NOT supported by Netware 386 versions shipped after
  34.      December 1990, because they use pipe mechanisms, which cause a
  35.      considerable deal of server overhead.
  36.      These functions are not implemented in this unit.
  37.      Use IPX/SPX peer-to-peer communication instead (nwComm).
  38.  (2) Network msg file no longer supported by 3.x
  39. }
  40.  
  41. Var result:word;
  42.  
  43. {F215/09 [2.15c+]}
  44. Function BroadcastToConsole(message:string):boolean;
  45. { broadcast a message to the file server console.
  46.   The message (max 60 chars, in ascii range [$20..$7E]) will be displayed
  47.   at the bottom of the console screen.
  48.   This function truncates the messagelength to 60 and repaces illegal
  49.   characters with a . }
  50.  
  51. {F215/02 [ ? ]}
  52. Function DisableStationBroadcast:boolean;
  53. { Allows a station to refuse broadcast messages. }
  54.  
  55. {F215/03 [ ? ]}
  56. Function EnableStationBroadcast:boolean;
  57. { Allows a station to accept broadcast messages. }
  58.  
  59. {F215/01 [2.15c+]}
  60. Function GetBroadcastMessage(var bmessage: string):boolean;
  61. { An application should poll this to see if there is a broadcastmessage
  62.   stored (for this workstation) at the default server.
  63.   The message mode must be 2 or 3. (No Notification by Shell)
  64.   If no message was stored at the server, or the message was empty,
  65.   this function will return FALSE and an errorcode of $103. }
  66.  
  67. {DE..(..04) [1.x/2.x/ 3.x]}
  68. Function GetBroadcastMode(var bmode:byte):boolean;
  69. { Returns the message mode.
  70.  
  71.   00 Server Stores : Netware Messages and User Messages,
  72.      Shell automaticly displays messages.
  73.   01 Server Stores : Server Messages. (User messages discarded)
  74.      Shell automaticly displays messages.
  75.   02 Server stores : Server messages only.
  76.      Applications have to use GetBroadCastMessage to see if there is a message.
  77.   03 Server stores : Server messages and User messages.
  78.      Applications have to use GetBroadCastMessage to see if there is a message. }
  79.  
  80.  
  81. {F215/00 [2.15c+]}
  82. Function SendBroadcastMessage( message:string;
  83.                                connCount:byte;
  84.                                connList:TconnectionList;
  85.                                VAR resultlist:TconnectionList ):boolean;
  86. { Sends a broadcast message to a number of logical connections.
  87.   The connectionlist is an array[1..connCount] of logical connection numbers,
  88.   the result of the broadcast can be found in the resultList parameter. }
  89.  
  90. {DE..(..0n) n=0,1,2,3 [1.x/2.x/3.x]}
  91. Function SetBroadcastMode(bmode:byte):boolean;
  92.  
  93.  
  94. {F217/D1 [2.15c+]}
  95. Function SendConsoleBroadcast(message:string; connCount:byte;
  96.                               connList:TconnectionList       ):boolean;
  97. {Sends a message to a number of connections, as if the message was send
  98.  by a console broadcast command. Console oprator privileges required.
  99.  If connCount equals 0, then the message is send to all connections. }
  100.  
  101. {--------------------Secondary Functions-------------------------------}
  102.  
  103. Procedure SendMessageToUser(UserName,Message:String);
  104. { sends a message to a (group of) users.
  105.   The username may contain wildcards (* and ?).
  106.   The message will not be received by stations whose status is CASTOFF.}
  107.  
  108.  
  109. IMPLEMENTATION {============================================================}
  110.  
  111. USES Dos,nwConn;
  112.  
  113. Var UnitReqBuffer:array[1..576] of byte;
  114.     UnitReplyBuffer:array[1..576] of byte;
  115.     UnitRegs:registers;
  116.  
  117. Procedure F2SystemCall(subf:byte;req_size,rep_size:word);
  118. begin
  119. With UnitRegs
  120.  do begin
  121.     DS := Seg(UnitReqBuffer);  SI := Ofs(UnitReqBuffer);   CX := Req_size;
  122.     ES := Seg(UnitReplyBuffer);DI := Ofs(UnitReplyBuffer); DX := rep_size;
  123.     AH := $F2; AL := subf;
  124.     MSDOS(UnitRegs);
  125.     Result:=al;
  126.     end;
  127. end;
  128.  
  129. {DE..(..04) [1.x/2.x/ 3.x]}
  130. Function GetBroadcastMode(var bmode:byte):boolean;
  131. { Returns the message mode.
  132.  
  133.   00 Server Stores : Netware Messages and User Messages,
  134.      Shell automaticly displays messages.
  135.   01 Server Stores : Server Messages. (User messages discarded)
  136.      Shell automaticly displays messages.
  137.   02 Server stores : Server messages only.
  138.      Applications have to use GetBroadCastMessage to see if there is a message.
  139.   03 Server stores : Server messages and User messages.
  140.      Applications have to use GetBroadCastMessage to see if there is a message. }
  141. var regs : registers;
  142. begin
  143. regs.ah := $de;
  144. regs.dl := $04;
  145. msdos(regs);
  146. bmode := regs.al;
  147. result:=$00; { the call has no return codes }
  148. GetBroadCastMode:=True;
  149. end;
  150.  
  151.  
  152. {DE..(..0n) n=0,1,2,3 [1.x/2.x/3.x]}
  153. Function SetBroadcastMode(bmode:byte):boolean;
  154. { Sets the new message mode.
  155.  
  156.   possible resultcode: $FF ( illegal broadcastmode supplied or
  157.                              the broadcastmode after the call is not equal
  158.                              to the intended broadcast mode )
  159.  
  160.   00 Server Stores : Netware Messages and User Messages,
  161.      Shell automaticly displays messages.
  162.   01 Server Stores : Server Messages. (User messages discarded)
  163.      Shell automaticly displays messages.
  164.   02 Server stores : Server messages only.
  165.      Applications have to use GetBroadCastMessage to see if there is a message.
  166.   03 Server stores : Server messages and User messages.
  167.      Applications have to use GetBroadCastMessage to see if there is a message.     }
  168. var regs : registers;
  169. begin
  170. if (bmode <4)
  171.  then begin
  172.       regs.ah := $de;
  173.       regs.dl := bmode;
  174.       msdos(regs);
  175.       if regs.al<>bmode  { if confirmation of new mode unequal desired mode }
  176.        then result:=$FF
  177.        else result:=$00;
  178.       end
  179.  else result:=$FF;
  180. SetBroadcastMode:=(result=0);
  181. end;
  182.  
  183.  
  184.  
  185. {F215/01 [2.15c+]}
  186. Function GetBroadcastMessage(var bmessage: string):boolean;
  187. { An application should poll this to see if there is a broadcastmessage
  188.   stored (for this workstation) at the default server.
  189.   The message mode must be 2 or 3. (No Notification by Shell)
  190.   If no message was stored at the server, or the message was empty,
  191.   this function will return FALSE and an errorcode of $103. }
  192. Var req:record
  193.         len      :word;
  194.         subF     :byte;
  195.         end                      ABSOLUTE UnitReqBuffer;
  196.     reply:record
  197.           _message:string[55];
  198.           end                    ABSOLUTE UnitReplyBuffer;
  199. BEGIN
  200. With req
  201.  do begin
  202.     subF:=$01;
  203.     len:=1;
  204.     end;
  205. F2SystemCall($15,sizeOf(req),sizeOf(reply));
  206. If result=0
  207.  then bmessage:=reply._message;
  208.  
  209. if bmessage[0]=#0 then result:=$103; { whups! empty message }
  210.  
  211. GetBroadCastMessage:=(result=0);
  212. { returncodes:
  213.   00 Successful; FC Message Queue Full;
  214.   FE I/O failure: Lack of dynamic workspace.
  215.   103 No msgs stored at server. }
  216. end;
  217.  
  218.  
  219. {F215/00 [2.15c+]}
  220. Function SendBroadcastMessage( message:string;
  221.                                connCount:byte;
  222.                                connList:TconnectionList;
  223.                                VAR resultlist:TconnectionList ):boolean;
  224. { Sends a broadcast message to a number of logical connections.
  225.   The connectionlist is an array[1..connCount] of logical connection numbers,
  226.   the result of the broadcast can be found in the resultList parameter.
  227.   example:
  228.     connCount=5
  229.     connList=  [ 4,9,1,5,2 ]
  230.  
  231.     resultList= [$00, $00, $FC, $FD, $FF]
  232.  
  233.     possible codes in resultList:
  234.       $00: broadcast to this logical connnection was successful.
  235.       $FC: message rejected, buffer for this station already contains a message,
  236.       $FD: invalid connection number
  237.       $FF: The target connection has blocked incoming messages,
  238.            or the target connection is not in use. }
  239. Var req:record
  240.         len      :word;
  241.         subF     :byte;
  242.         _connCount     :byte;
  243.         connLandMessage:array[1..306] of byte; { 250 conn, 56 msg }
  244.         end                                ABSOLUTE UnitReqBuffer;
  245.     reply:record
  246.           connCount:byte;
  247.           _ResultList:TconnectionList;
  248.           end                              ABSOLUTE UnitReplyBuffer;
  249.    t:byte;
  250. BEGIN
  251. With req
  252.  do begin
  253.     subF:=$00;
  254.     _connCount:=connCount;
  255.     move(connList[1],connLandMessage[1],connCount);
  256.     t:=ord(message[0]); if t>55 then t:=55;
  257.     move(message[0],connLandMessage[connCount+1],t+1);
  258.     len:=3+connCount+t; { 2 bytes + [connList] + len(str) + str[0] }
  259.     end;
  260. F2SystemCall($15,sizeOf(req),sizeOf(reply));
  261. If result=0
  262.  then with reply
  263.        do begin
  264.           resultList:=_resultlist;
  265.           end;
  266.  
  267. SendBroadcastMessage:=(result=0);
  268. end;
  269.  
  270.  
  271. {F215/09 [2.15c+]}
  272. Function BroadcastToConsole(message:string):boolean;
  273. { broadcast a message to the file server console.
  274.   The message (max 60 chars, in ascii range [$20..$7E]) will be displayed
  275.   at the bottom of the console screen.
  276.   This function truncates the messagelength to 60 and repaces illegal
  277.   characters with a . }
  278. Var req:record
  279.         len      :word;
  280.         subF     :byte;
  281.         _message :string;
  282.         end               ABSOLUTE UnitReqBuffer;
  283.    t:byte;
  284. BEGIN
  285. With req
  286.  do begin
  287.     subF:=$09;
  288.     PstrCopy(_message,message,60);
  289.     for t:=1 to 60
  290.       do if (_message[t]<>#$0) and
  291.             ((_message[t]<#$20) or (_message[t]>#$7E))
  292.          then _message[t]:='.';
  293.     len:=62;
  294.     end;
  295. F2SystemCall($15,sizeOf(req),0);
  296. BroadcastToConsole:=(result=0);
  297. { resultcodes:  00 success ; $FC message queue full ;
  298.                $FE I/O failure: lack of dynamic workspace }
  299. end;
  300.  
  301.  
  302. {F215/02 [2.15c+]}
  303. Function DisableStationBroadcast:boolean;
  304.  
  305. Var req:record
  306.         len      :word;
  307.         subF     :byte;
  308.         end                 ABSOLUTE UnitReqBuffer;
  309. BEGIN
  310. With req
  311.  do begin
  312.     subF:=$02;
  313.     len:=1;
  314.     end;
  315. F2SystemCall($15,SizeOf(req),0);
  316. DisableStationBroadcast:=(result=0);
  317. end;
  318.  
  319.  
  320. {F215/03 [2.15c+]}
  321. Function EnableStationBroadcast:boolean;
  322. Var req:record
  323.         len      :word;
  324.         subF     :byte;
  325.         end                ABSOLUTE UnitReqBuffer;
  326. BEGIN
  327. With req
  328.  do begin
  329.     subF:=$03;
  330.     len:=1;
  331.     end;
  332. F2SystemCall($15,sizeOf(req),0);
  333. EnableStationBroadcast:=(result=0);
  334. end;
  335.  
  336.  
  337.  
  338. {F217/D1 [2.15c+]}
  339. Function SendConsoleBroadcast(message:string; connCount:byte;
  340.                               connList:TconnectionList       ):boolean;
  341. {Sends a message to a number of connections, as if the message was send
  342.  by a console oprator. Console oprator privileges required.
  343.  If connCount equals 0, then the message is send to all connections. }
  344. Var req:record
  345.         len      :word;
  346.         subF     :byte;
  347.         _ConnCount:byte;
  348.         _connAndMess:array[1..306] of byte;
  349.         end                           ABSOLUTE UnitReqBuffer;
  350.    t:byte;
  351. BEGIN
  352. With req
  353.  do begin
  354.     subF:=$D1;
  355.     _connCount:=connCount;
  356.     Move(connList[1],_connAndMess[1],connCount);
  357.     t:=ord(message[0]); if t>55 then t:=55;
  358.     {!! to do: strip hi-bit of message.. }
  359.     Move(message[0],_connAndMess[connCount+1],t+1);
  360.     len:=t+connCount+3;
  361.     end;
  362. F2SystemCall($17,sizeOf(req),0);
  363. SendConsoleBroadcast:=(result=0);
  364. {Resultcodes: $00 success; $C6 No Console Rights}
  365. end;
  366.  
  367. {=================== Secondary Functions ===================================}
  368.  
  369. Procedure SendMessageToUser(UserName,Message:String);
  370. { sends a message to a (group of) users.
  371.   The username may contain wildcards (* and ?).
  372.   The message will not be received by stations whose status is CASTOFF.}
  373. { calls nwConn.getObjectConnectionNumber and nwMess.SendBroadcastMessage }
  374. Var NbrOfConn:byte;
  375.     connList,ResultList:TconnectionList;
  376. begin
  377. IF NwConn.GetObjectConnectionNumbers(UserName,1 {OT_USER},NbrOfConn,connList)
  378.    AND (NbrOfConn>0)
  379.  then SendBroadcastMessage(Message,NbrOfConn,connList,ResultList);
  380. end;
  381.  
  382.  
  383. end. {unit nwMess}
  384.